﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MpSoft.Library.BUSS.Settings;
using MpSoft.Library.BUSS.Categories;
using MpSoft.Basic.Utils;

namespace MpSoft.Web.Controls.Layouts
{
    public partial class Layout_3C : System.Web.UI.UserControl
    {
        #region Var

        private string[] DayWeeks = { "Chủ nhật", "Thứ 2", "Thứ 3", "Thứ 4", "Thứ 5", "Thứ 6", "Thứ 7" };

        #endregion

        #region Method
       
        public string getBanner()
        {
            return "<a href='/'><img src='" + SettingBUSS.GetSettingValue("bannerimage") + "'/></a>";
        }

        public string getMenuTop()
        {
            return MenuBUSS.GetByMenuID(0, "menu-top");
        }

        public string GetDate()
        {
            var dt = DateTime.Now;
            return string.Format("{0:hh:mm}  " + DayWeeks[(int)dt.DayOfWeek] + ", {1:dd/MM/yyy}", dt, dt);
        }

        private void BindControl()
        {
            LoadControl.UserControl = UserControl;
        }

        #endregion

        #region Event

        protected void Page_Load(object sender, EventArgs e)
        {
            BindControl();
        }

        protected void cmdSearch_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtSearch.Text))
            {
                string keyword = CommonHelper.FillterChar(txtSearch.Text);
                Session["newsKeyword"] = txtSearch.Text;
                Response.Redirect(SEOHelper.UrlSenameTitle("tim-kiem-tin", keyword), false);
            }
        }

        #endregion
        
        #region Properties
        
        public string UserControl { set; get; }

        #endregion
    }
}